package com.example.localareanetworkchat.persistence.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.fasterxml.jackson.annotation.JsonProperty

@Entity(tableName = "chat_group")
data class ChatGroup(
    @JsonProperty("id")
    @PrimaryKey(autoGenerate = true)
    val id: Long,
    @JsonProperty("groupName")
    @ColumnInfo(name = "group_name")
    val groupName: String,
    @JsonProperty("userId")
    @ColumnInfo(name = "user_id")
    var userId: Long,
    @JsonProperty("uid")
    @ColumnInfo(name = "uid")
    var uid: String,
    @JsonProperty("chatGroupId")
    @ColumnInfo(name = "chat_group_id")
    val chatGroupId: String,
    @JsonProperty("groupInvitationCode")
    @ColumnInfo(name = "group_invitation_code")
    val groupInvitationCode: String,
    @JsonProperty("groupSubInvitationCode")
    @ColumnInfo(name = "group_sub_invitation_code")
    var groupSubInvitationCode: String,
    @JsonProperty("groupType")
    @ColumnInfo(name = "group_type")
    var groupType: String,// CREATE or JOIN
    @JsonProperty("joinAddress")
    @ColumnInfo(name = "join_address")
    var joinAddress: String,
    @JsonProperty("createTime")
    @ColumnInfo(name = "create_time")
    val createTime: String,
    @JsonProperty("groupMetaData")
    @ColumnInfo(name = "group_meta_data")
    var groupMetaData: String,
    @JsonProperty("dhcpIp")
    @ColumnInfo(name = "dhcp_ip")
    var dhcpIp: Int
)

// 群组元信息
data class ChatGroupMetaData(
    @JsonProperty("creatorName")
    val creatorId: String,
    @JsonProperty("groupName")
    val groupName: String,
    @JsonProperty("chatGroupId")
    val chatGroupId: String,
    @JsonProperty("createTime")
    val createTime: String,
    @JsonProperty("dismiss")
    val dismiss: Int,
    @JsonProperty("version")
    val version: Int,
    @JsonProperty("dhcpIp")
    val dhcpIp: Int
    )

class GroupAddType {
    companion object {
        const val GROUP_ADD_TYPE_CREATE = "CREATE"
        const val GROUP_ADD_TYPE_JOIN = "JOIN"
    }
}